package fi.foyt.cs.android;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import android.content.res.AssetManager;
import android.content.res.Resources;
import android.util.AndroidRuntimeException;

public class Settings {

  public static String getSetting(String name) {
    return properties.getProperty(name);
  }
  
  public static void initSettings(Resources resources) {
    if (properties == null) {
      properties = new Properties();

      AssetManager assetManager = resources.getAssets();

      try {
        InputStream inputStream = assetManager.open("settings.properties");
        properties.load(inputStream);
      } catch (IOException e) {
        throw new AndroidRuntimeException(e);
      }
    }    
  }

  private static Properties properties = null;
}
